
// 轮播图
function lunbotu() {
    this.ul = document.querySelector(".lun_ul");
    this.li = this.ul.querySelectorAll("li");
    this.timeout;
    this.ab;
    this.right = document.querySelector(".lb-right");
    this.zuo = document.querySelector(".lb-left");
    this.index = 0;
    this.Next()

}
lunbotu.prototype.Next = function () {
    let _this = this;
    _this.right.onclick = function () {
        _this.index = _this.index + 1
        if (_this.index == 9) {
            $(_this.ul).animate({
                left: 0
            }, 0)
            _this.index = 1
        }
        _this.Change()
    }
    _this.zuo.onclick = function () {
        clearInterval(_this.ab)
        _this.index = _this.index - 1;
        if (_this.index <= 0) {
            $(_this.ul).animate({
                left: -9040
            }, 0)
            _this.index = 8
        }
        _this.Change()
    }
    _this.ul.onmouseover = function () {

        clearInterval(_this.ab)
    }

    _this.timeout = function time() {
        clearInterval(_this.ab)
        _this.ab = setInterval(function () {
            _this.index = _this.index + 1
            if (_this.index == 9) {
                $(_this.ul).animate({
                    left: 0
                }, 0)
                _this.index = 1
            }
            _this.Change()
        }, 4000)
    }

    _this.timeout()

    _this.ul.onmouseout = function () {
        _this.timeout()
    }


}

lunbotu.prototype.Change = function () {
    let _this = this;
    $(_this.ul).stop().animate({
        left: -1130 * (_this.index)
    }, 3000)
}




let lunbo = new lunbotu();



// 换图片
let wx = document.querySelector(".weixin");
let wb = document.querySelector(".weibo");
let img1 = document.querySelector(".img1");
let img2 = document.querySelector(".img2");

wx.onmouseover = () => {
    img1.setAttribute("src", "./images/wechat.svg");
}
wx.onmouseout = () => {
    img1.setAttribute("src", "./images/weixin.svg");
}


wb.onmouseover = () => {
    img2.setAttribute("src", "./images/weibo_ho.svg");
}
wb.onmouseout = () => {
    img2.setAttribute("src", "./images/wei'bo.svg");
}


let xuan = document.querySelector(".xuan");
let box = document.querySelector(".boxbox");


// 回到顶部
let back = document.querySelector(".back");
back.style.top = "0px"
back.style.left = window.innerWidth - 80 + "px"
let dibu = document.querySelector("#dibu");
// console.log(dibu.offsetTop)
let b = xuan.offsetTop;
// 粘性定位
window.onscroll = () => {
    let a = document.documentElement.scrollTop || document.body.scrollTop;

    if (a >= b) {
        box.style.height = "100px"
        xuan.setAttribute("class", "xuan tes")
    }
    if (a < b) {
        xuan.setAttribute("class", "xuan")
        box.style.height = "0"
    }
    // 回到顶部
    if (a > 584) {
        back.style.display = "block";
        back.style.top = a - 200 + "px"
        // console.log(a)
        if (a + 484 > dibu.offsetTop) {
            back.style.top = dibu.offsetTop - 684 + "px"
        }
    }
    if (a < 584) {
        back.style.display = "none"
    }
}

back.onclick = () => {
    $("body,html").stop().animate({
        scrollTop: "0px"
    }, 1500)
}


